package com.xy.gateway.servlet;

/***********************************************************************
 * Module:  EpayGateReqServlet.java
 * Author:  ligh1
 * Purpose: Defines the Class EpayGateReqServlet
 ***********************************************************************/

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.xy.gateway.exception.GateWayException;
import com.xy.gateway.request.RequestBuilder;

/** @pdOid 04a820f9-2f9b-4ea4-94b6-dd2adcd4c362 */
public class EpayGateReqServlet extends HttpServlet {
	private static final Logger log = LoggerFactory
	.getLogger(EpayGateReqServlet.class);
	// @Override
	// public void service(ServletRequest req, ServletResponse res)
	// throws ServletException, IOException {
	// HttpServletRequest req1 = (HttpServletRequest) req;
	// HttpServletResponse res1 = (HttpServletResponse) res;
	// EpayControler controler = new EpayControler(req1);
	// if (!controler.isValidRequest()) {
	// //
	// return;
	// }
	// RequestBuilder builder = new RequestBuilder();
	// builder.buildRequest(req1, res1);
	// }

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse res) {

		RequestBuilder builder = new RequestBuilder();
		try {
			builder.buildRequest(req, res);
		} catch (GateWayException e) {
			e.printStackTrace();
			log.error(e.getLocalizedMessage(), e);
			try {
				req.getRequestDispatcher("V5/CN/STY1/ErrorPage.jsp").forward(req, res);
			} catch (Exception e1) {
				log.error(e1.getLocalizedMessage(), e1);
			}  
		}
	}
}